#!/bin/bash

# 停止并禁用 CUPS 相关服务
systemctl stop cups.service cups.socket cups-browsed.service 2>/dev/null
systemctl disable cups.service cups.socket cups-browsed.service 2>/dev/null

# 卸载所有 CUPS 相关包
if command -v dnf >/dev/null 2>&1; then
    dnf remove -y $(rpm -qa | grep '^cups') 2>/dev/null
elif command -v yum >/dev/null 2>&1; then
    yum remove -y $(rpm -qa | grep '^cups') 2>/dev/null
elif command -v apt-get >/dev/null 2>&1; then
    apt-get remove --purge -y cups cups-bsd cups-client cups-common cups-core-drivers cups-daemon cups-ipp-utils cups-ppdc cups-server-common 2>/dev/null
fi

# 验证
if rpm -qa 2>/dev/null | grep -q '^cups'; then
    echo "[-] CUPS 包仍然存在"
    exit 1
else
    echo "[+] CUPS 相关包已卸载"
    exit 0
fi
